package beer.coder.walawala.common.config;

import beer.coder.walawala.common.constant.AfterActionType;
import beer.coder.walawala.common.constant.Constant;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * TODO
 *
 * @author amath0312
 * @version 1.0
 * @date 2019-10-24 21:08
 */
public class ApplicationConfigure {

  public static final String DEFAULT_RESOURCE_PATH = "resources";
  public static final Integer DEFAULT_START_X = -10;
  public static final Integer DEFAULT_START_Y = 10;
  public static final Integer DEFAULT_WIDTH = 640;
  public static final Integer DEFAULT_HEIGHT = 480;
  public static final AfterActionType DEFAULT_AFTER_ACTION = AfterActionType.NONE;

  protected Integer startx;
  protected Integer starty;
  protected Integer width;
  protected Integer height;

  protected String name = Constant.APPNAME;
  protected String resourcePath;
  protected String version = Constant.VERSION;
  protected AfterActionType afterActionType = DEFAULT_AFTER_ACTION;
  protected List<TabConfigure> tabs;

  public String getResourcePath() {
    return resourcePath;
  }

  public void setResourcePath(String resourcePath) {
    this.resourcePath = resourcePath;
  }

  public String getVersion() {
    return version;
  }

  public TabConfigure[] getTabs() {
    if (this.tabs == null) {
      return new TabConfigure[0];
    } else {
      return tabs.toArray(new TabConfigure[0]);
    }
  }

  public void setTabs(TabConfigure[] tabs) {
    this.tabs = new LinkedList<>();
    Collections.addAll(this.tabs, tabs);
  }

  public void addTab(TabConfigure tab) {
    if (this.tabs == null) {
      this.tabs = new LinkedList<>();
    }
    this.tabs.add(tab);
  }

  public void remoteTab(TabConfigure tab) {
    if (this.tabs == null) {
      this.tabs = new LinkedList<>();
    }
    if (this.tabs.contains(tab)) {
      this.tabs.remove(tab);
    }
  }

  public Integer getStartx() {
    return startx;
  }

  public void setStartx(Integer startx) {
    this.startx = startx;
  }

  public Integer getStarty() {
    return starty;
  }

  public void setStarty(Integer starty) {
    this.starty = starty;
  }

  public Integer getWidth() {
    return width;
  }

  public void setWidth(Integer width) {
    this.width = width;
  }

  public Integer getHeight() {
    return height;
  }

  public void setHeight(Integer height) {
    this.height = height;
  }

  public String getName() {
    return name;
  }

  public AfterActionType getAfterActionType() {
    return afterActionType;
  }

  public void setAfterActionType(AfterActionType afterActionType) {
    this.afterActionType = afterActionType;
  }
}
